/**
 * @FileName: MyApplicationFailedEventListener.java
 * @Package: com.springboot.listener
 * @author lig134
 * @created 2017/3/7 10:49
 * <p>
 * Copyright 2015 ziroom
 */
package com.springboot.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.context.ApplicationListener;

/**
 * <p></p>
 *spring boot启动异常处理
 * <PRE>
 * <BR>	修改记录
 * <BR>-----------------------------------------------
 * <BR>	修改日期			修改人			修改内容
 * </PRE>
 *  异常发生时，虚拟机对资源新型回收和释放
 * @author lig134
 * @since 1.0
 * @version 1.0
 */
public class MyApplicationFailedEventListener implements ApplicationListener<ApplicationFailedEvent>{
    Logger logger= LoggerFactory.getLogger(MyApplicationFailedEventListener.class);
    @Override
    public void onApplicationEvent(ApplicationFailedEvent applicationFailedEvent) {
        Throwable throwable=applicationFailedEvent.getException();
        handleThrowable(throwable);
    }

    private void handleThrowable(Throwable throwable){
        logger.error("异常信息：",throwable);
    }
}